package replace.data.value.with.object;

import java.util.Collection;
import java.util.Iterator;

/**
 * Created by Administrator on 2018/1/25.
 */
public class Order {

    /* 数据值
    private String customer;*/
    //将对象取代数据值
    private CustomerRF customerRF;

    public Order(String customer) {
//        this.customer = customer;
        //将对象取代数据值
        this.customerRF = new CustomerRF(customer);
    }

    public String getCustomer() {
//        return customer;
        //将对象取代数据值
        return customerRF.getName();
    }

    public void setCustomer(String customer) {
//        this.customer = customer;
        //将对象取代数据值
        this.customerRF = new CustomerRF(customer);
    }

    private static int numberOfOrdersFor(Collection orders, String customer) {
        int result = 0;
        Iterator iterator = orders.iterator();
        while (iterator.hasNext()) {
            Order each = (Order) iterator.next();
            if (each.getCustomer().equals(customer)) {
                result++;
            }
        }
        return result;
    }
}
